﻿<?php


//$id = empty($_GET['id']) ? 0 : intval($_GET['id']);
//if(!empty($id)){
	$oAdmin = new Admin();
	$info = $oAdmin->get_row($__s_manager_self['id'], null, '*');
	
	$vars['info'] = $info;
//}


	$oRole = new Role();
	$roleinfo = $oRole->get_row($info['role'], '*');
	$roleinfo['setting'] = @unserialize($roleinfo['setting']);
	$_menus = @unserialize($roleinfo['menus']);
	$_powers = @unserialize($roleinfo['powers']);
	$_access = @unserialize($roleinfo['access']);
	
	$_f_menus = cache_read('menus.php');
	$menu_tree = my_role_ul($_f_menus['menu_tree'], $_menus, $_powers);
	$vars['menu_tree'] = $menu_tree;
	
	function my_role_ul($menu_tree, $menus = array(), $powers = array()){
		global $__l;	// 语言包
		$menu_arr = array();
		foreach($menu_tree as $menu){
			$power =  unserialize($menu['power']);
			if(!empty($power)){
				foreach($power as $key => $val){
					$power[$val] = $__l[$val];
					unset($power[$key]);
				}
			}
			if(in_array($menu['id'], $menus)){
				$box_arr = array('<ul class="chlist">');
				if(is_array($power)){
					foreach($power as $key => $text){
						if(isset($powers) && !empty($powers) && in_array($key, $powers)){
							$box_arr[] = "<li><label title=\"{$key}\" class=\"poshytip\">{$text}</label></li>";
						}
					}
				}
				$box_arr[] = '</ul>';
				$__powers = implode('', $box_arr);
				$menu_arr[] = '<li><div class="menu"><label title="'.$menu['name'].'" class="poshytip">'.$__l[$menu['name']].'</label></div><div class="power">'.$__powers.'</div><div class="clear"></div>';
			}
	
			if(isset($menu['menus']) && is_array($menu['menus'])){
				$menu_arr[] = '<ul>'.my_role_ul($menu['menus'], $menus, $powers).'</ul>';
			}
			$menu_arr[] = '</li><div class="clear"></div>';
		}
		return implode("\n", $menu_arr);
	}
?>
